﻿<?xml version="1.0" encoding="utf-8" ?>
<Recipe Name="CreateVSService" xmlns="http://schemas.microsoft.com/pag/gax-core"
                               xmlns:xi="http://www.w3.org/2001/XInclude" Bound="false">
  <DocumentationLinks>
    <Link Kind="Documentation" Caption="VS Services general" Url="ms-help://MS.VSCC.v90/MS.VSIPCC.v90/MS.VSSDK.v90/dv_vsintegration/html/c0b415ba-b825-4da0-9faf-8a60a663e302.htm" />
    <Link Kind="Documentation" Caption="How to: Consume a VS Service" Url="ms-help://MS.VSCC.v90/MS.VSIPCC.v90/MS.VSSDK.v90/dv_vsintegration/html/1f000020-8fb7-4e39-8e1e-2e38c7fec3d4.htm" />
    <Link Kind="Documentation" Caption="How to: Provide a VS Service" Url="ms-help://MS.VSCC.v90/MS.VSIPCC.v90/MS.VSSDK.v90/dv_vsintegration/html/12bc1f12-47b1-44f6-b8db-862aa88d50d1.htm" />
  </DocumentationLinks>  
  <xi:include href="../Common/CommonTypeAliases.xml"
				xpointer="xmlns(gax=http://schemas.microsoft.com/pag/gax-core) xpointer(/gax:Types)" />
  <Caption>VS Service</Caption>
  <Description>VS Service</Description>
  <HostData>
    <Icon ID="5795" />
    <CommandBar Menu="VSSDKAssistProjectCreate"/>
  </HostData>
  <Arguments>
    <xi:include href="../Common/CommonArguments.xml"
					  xpointer="xmlns(gax=http://schemas.microsoft.com/pag/gax-core) xpointer(/gax:Arguments/gax:Argument)" />
    <Argument Name="VSPackageProject" Type="EnvDTE.Project, EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Required="true">
      <ValueProvider Type="VSSDKAssist.Assets.ValueProviders.VisualStudio.CurrentlySelectedProjectValueProvider, VSSDKAssist.Assets"
                     Stage="OnBeginRecipe"/>
    </Argument>
    <Argument Name="VSPackageProjectNamespace" Required="true">
      <ValueProvider Type="Evaluator"
                     Expression="$(VSPackageProject.Properties.Item('DefaultNamespace').Value.ToString())"
                     Stage="OnBeginRecipe">
      </ValueProvider>
    </Argument>
    <Argument Name="DestinationFolder" Required="true">
      <ValueProvider Type="Evaluator" 
                     Expression="Services" 
                     Stage="OnBeginRecipe" />
    </Argument>    
    <Argument Name="ServiceNamespace" Required="true">
      <ValueProvider Type="Evaluator"
                     Expression="$(VSPackageProjectNamespace).$(DestinationFolder)"
                     Stage="OnBeginRecipe">
        <MonitorArgument Name="VSPackageProjectNamespace"/>
        <MonitorArgument Name="DestinationFolder"/>
      </ValueProvider>
    </Argument>    
    <Argument Name="IServiceGuid" Type="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Required="true">
      <ValueProvider Type="VSSDKAssist.Assets.ValueProviders.Framework.GuidValueProvider, VSSDKAssist.Assets"
                     Stage="OnBeginRecipe"/>
    </Argument>
    <Argument Name="SServiceGuid" Type="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Required="true">
      <ValueProvider Type="VSSDKAssist.Assets.ValueProviders.Framework.GuidValueProvider, VSSDKAssist.Assets"
                     Stage="OnBeginRecipe"/>
    </Argument>
    <Argument Name="LanguageExtension" Required="true">
      <ValueProvider Type="VSSDKAssist.Assets.ValueProviders.VisualStudio.CurrentlySelectedProjectLanguageValueProvider, VSSDKAssist.Assets"
               Stage="OnBeginRecipe">
      </ValueProvider>
    </Argument>
    <Argument Name="ServiceName" Required="true"/>
    <Argument Name="IServiceClassFileName">
      <ValueProvider Type="Evaluator" Expression="I$(ServiceName).$(LanguageExtension)"
                     Stage="OnBeginRecipe">
        <MonitorArgument Name="ServiceName"/>
      </ValueProvider>
    </Argument>
    <Argument Name="SServiceClassFileName">
      <ValueProvider Type="Evaluator"
                     Expression="S$(ServiceName).$(LanguageExtension)"
                     Stage="OnBeginRecipe">
        <MonitorArgument Name="ServiceName"/>
      </ValueProvider>
    </Argument>
    <Argument Name="ServiceClassFileName">
      <ValueProvider Type="Evaluator" 
                     Expression="$(ServiceName).$(LanguageExtension)"
                     Stage="OnBeginRecipe">
        <MonitorArgument Name="ServiceName"/>
      </ValueProvider>
    </Argument>
    <Argument Name="VSPackageCodeClass" Type="EnvDTE.CodeClass, EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Required="true">
      <ValueProvider Type="VSSDKAssist.Recipes.Common.ValueProviders.VSPackageCodeClassValueProvider, VSSDKAssist"
                     Stage="OnBeginRecipe"/>
    </Argument>
    <Argument Name="IServiceTT">
      <ValueProvider Type="VSSDKAssist.Recipes.Common.ValueProviders.TTPathValueProvider, VSSDKAssist"
                     Stage="OnBeginRecipe"
                     SubPath="VSService"
                     TTFile="IService.tt">
      </ValueProvider>
    </Argument>
    <Argument Name="SServiceTT">
      <ValueProvider Type="VSSDKAssist.Recipes.Common.ValueProviders.TTPathValueProvider, VSSDKAssist"
                     Stage="OnBeginRecipe"
                     SubPath="VSService"
                     TTFile="SService.tt">
      </ValueProvider>
    </Argument>
    <Argument Name="ServiceClassTT">
      <ValueProvider Type="VSSDKAssist.Recipes.Common.ValueProviders.TTPathValueProvider, VSSDKAssist"
                     Stage="OnBeginRecipe"
                     SubPath="VSService"
                     TTFile="ServiceClass.tt">
      </ValueProvider>
    </Argument>
    <Argument Name="ServiceInitializeTT">
      <ValueProvider Type="VSSDKAssist.Recipes.Common.ValueProviders.TTPathValueProvider, VSSDKAssist"
                     Stage="OnBeginRecipe"
                     SubPath="VSService"
                     TTFile="ServiceInitialize.tt">
      </ValueProvider>
    </Argument>
    <Argument Name="CreateServiceTT">
      <ValueProvider Type="VSSDKAssist.Recipes.Common.ValueProviders.TTPathValueProvider, VSSDKAssist"
                     Stage="OnBeginRecipe"
                     SubPath="VSService"
                     TTFile="CreateService.tt">
      </ValueProvider>
    </Argument>
    <Argument Name="ProvideServiceAttributeTT">
      <ValueProvider Type="VSSDKAssist.Recipes.Common.ValueProviders.TTPathValueProvider, VSSDKAssist"
                     Stage="OnBeginRecipe"
                     SubPath="VSService"
                     TTFile="ProvideServiceAttribute.tt">
      </ValueProvider>
    </Argument>
  </Arguments> 
  <GatheringServiceData>
    <Wizard xmlns="http://schemas.microsoft.com/pag/gax-wizards" SchemaVersion="1.0">
      <Pages>
        <Page Type="VSSDKAssist.Recipes.CreateVSService.CreateVSServiceCP, VSSDKAssist"
              Height="100" Width="510">
          <Title>Specify service general properties</Title>
          <LinkTitle>Service general properties</LinkTitle>
        </Page>
      </Pages>
    </Wizard>
  </GatheringServiceData>
  <Actions CoordinatorServiceType="VSSDKAssist.Recipes.Common.Coordinators.ExecutionProgressCoordinator, VSSDKAssist">
    <!--Create Folder-->
    <Action Name="GenerateDestinationFolder"
          Type="VSSDKAssist.Assets.Actions.VisualStudio.AddProjectFolderAction, VSSDKAssist.Assets"
          StatusMessage="Creating destination folder"
          WriteMessageToOutputWindow="true">
      <Input Name="FolderName" RecipeArgument="DestinationFolder"/>
      <Output Name="FolderAdded" />
    </Action>    
    <!--Create IService-->
    <Action Name="GenerateIServiceContent"
          Type="Microsoft.Practices.RecipeFramework.VisualStudio.Library.Templates.TextTemplateAction, Microsoft.Practices.RecipeFramework.VisualStudio.Library"
          StatusMessage="Creating I interface"
          WriteMessageToOutputWindow="true">
      <Input Name="Template" RecipeArgument="IServiceTT"/>
      <Input Name="ServiceNamespace" RecipeArgument="ServiceNamespace"/>
      <Input Name="ServiceGuid" RecipeArgument="IServiceGuid"/>
      <Input Name="ServiceName" RecipeArgument="ServiceName"/>
      <Output Name="Content" />
    </Action>
    <Action Name="AddIServiceContent"
          Type="VSSDKAssist.Assets.Actions.VisualStudio.AddItemFromStringToProjectItemAction, VSSDKAssist.Assets"
          Open="true">
      <Input Name="Content" ActionOutput="GenerateIServiceContent.Content" />
      <Input Name="TargetFileName" RecipeArgument="IServiceClassFileName"/>
      <Input Name="InputProjectItem" ActionOutput="GenerateDestinationFolder.FolderAdded" />
    </Action>
    <!--Create SService-->
    <Action Name="GenerateSServiceContent"
          Type="Microsoft.Practices.RecipeFramework.VisualStudio.Library.Templates.TextTemplateAction, Microsoft.Practices.RecipeFramework.VisualStudio.Library"
          StatusMessage="Creating S interface"
          WriteMessageToOutputWindow="true">
      <Input Name="Template" RecipeArgument="SServiceTT"/>
      <Input Name="ServiceNamespace" RecipeArgument="ServiceNamespace"/>
      <Input Name="ServiceGuid" RecipeArgument="SServiceGuid"/>
      <Input Name="ServiceName" RecipeArgument="ServiceName"/>
      <Output Name="Content" />
    </Action>
    <Action Name="AddSServiceContent"
          Type="VSSDKAssist.Assets.Actions.VisualStudio.AddItemFromStringToProjectItemAction, VSSDKAssist.Assets"
          Open="true">
      <Input Name="Content" ActionOutput="GenerateSServiceContent.Content" />
      <Input Name="TargetFileName" RecipeArgument="SServiceClassFileName"/>
      <Input Name="InputProjectItem" ActionOutput="GenerateDestinationFolder.FolderAdded" />
    </Action>
    <!--Create Service-->
    <Action Name="GenerateServiceClassContent"
          Type="Microsoft.Practices.RecipeFramework.VisualStudio.Library.Templates.TextTemplateAction, Microsoft.Practices.RecipeFramework.VisualStudio.Library"
          StatusMessage="Creating service implementation class"
          WriteMessageToOutputWindow="true">
      <Input Name="Template" RecipeArgument="ServiceClassTT"/>
      <Input Name="ServiceNamespace" RecipeArgument="ServiceNamespace"/>
      <Input Name="ServiceName" RecipeArgument="ServiceName"/>
      <Output Name="Content" />
    </Action>
    <Action Name="AddServiceClassContent"
          Type="VSSDKAssist.Assets.Actions.VisualStudio.AddItemFromStringToProjectItemAction, VSSDKAssist.Assets"
          Open="true">
      <Input Name="Content" ActionOutput="GenerateServiceClassContent.Content" />
      <Input Name="TargetFileName" RecipeArgument="ServiceClassFileName"/>
      <Input Name="InputProjectItem" ActionOutput="GenerateDestinationFolder.FolderAdded" />
    </Action>
    <!--Add ProvideService attribute-->
    <Action Name="GenerateProvideServiceAttribute"
            Type="Microsoft.Practices.RecipeFramework.VisualStudio.Library.Templates.TextTemplateAction, Microsoft.Practices.RecipeFramework.VisualStudio.Library"
            StatusMessage="Adding service registration information"
            WriteMessageToOutputWindow="true">
      <Input Name="Template" RecipeArgument="ProvideServiceAttributeTT"/>
      <Input Name="ServiceName" RecipeArgument="ServiceName"/>
      <Input Name="ServiceNamespace" RecipeArgument="ServiceNamespace"/>
      <Output Name="Content" />
    </Action>
    <Action Name="AddProvideServiceAttribute"
            Type="VSSDKAssist.Recipes.Common.Actions.InsertAttributeToCodeClassAction, VSSDKAssist">
      <Input Name="CodeClass" RecipeArgument="VSPackageCodeClass"/>
      <Input Name="AttributeValue" ActionOutput="GenerateProvideServiceAttribute.Content"/>
    </Action>    
    <!--Add Service Initialize-->
    <Action Name="GenerateServiceInitializeContent"
          Type="Microsoft.Practices.RecipeFramework.VisualStudio.Library.Templates.TextTemplateAction, Microsoft.Practices.RecipeFramework.VisualStudio.Library">
      <Input Name="Template" RecipeArgument="ServiceInitializeTT"/>
      <Input Name="ServiceNamespace" RecipeArgument="ServiceNamespace"/>
      <Input Name="ServiceName" RecipeArgument="ServiceName"/>
      <Output Name="Content" />
    </Action>
    <Action Name="AddInitializeMethod" Type="VSSDKAssist.Recipes.Common.Actions.AddVSPackageInitializeFunctionAction, VSSDKAssist">
      <Input Name="CodeClass" RecipeArgument="VSPackageCodeClass" />
      <Output Name="CodeFunction" />
    </Action>
    <Action Name="InsertServiceInitialize" Type="VSSDKAssist.Assets.Actions.VisualStudio.InsertTextToCodeElementAction, VSSDKAssist.Assets">
      <Input Name="TextToInsert" ActionOutput="GenerateServiceInitializeContent.Content" />
      <Input Name="CodeElement" ActionOutput="AddInitializeMethod.CodeFunction" />
    </Action>
    <!--Add Service creator-->
    <Action Name="GenerateServiceCreatorContent"
          Type="Microsoft.Practices.RecipeFramework.VisualStudio.Library.Templates.TextTemplateAction, Microsoft.Practices.RecipeFramework.VisualStudio.Library">
      <Input Name="Template" RecipeArgument="CreateServiceTT"/>
      <Input Name="ServiceName" RecipeArgument="ServiceName"/>
      <Input Name="ServiceNamespace" RecipeArgument="ServiceNamespace"/>
      <Output Name="Content" />
    </Action>
    <Action Name="InsertServiceCreator" Type="VSSDKAssist.Assets.Actions.VisualStudio.InsertTextToCodeElementAction, VSSDKAssist.Assets">
      <Input Name="TextToInsert" ActionOutput="GenerateServiceCreatorContent.Content" />
      <Input Name="CodeElement" RecipeArgument="VSPackageCodeClass" />
    </Action>    
  </Actions>
</Recipe>